package com.hyy.formal;

import org.squirrelframework.foundation.fsm.*;

/**
 * Created by hyygavin on 2017/10/20.
 */
public class Exec {
    public static void main(String[] args) {
//        StateMachineBuilder<MyStateMachine, MyState, MyEvent, MyContext> builder =
//                StateMachineBuilderFactory.create(MyStateMachine.class, MyState.class, MyEvent.class, MyContext.class);
        UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(MyAbstractStateMachine.class);
        builder.externalTransition().from(MyState.A).to(MyState.B).on(MyEvent.GoToB).callMethod("fromto");
//        builder.externalTransition().from(MyState.A).to(MyState.B).on(MyEvent.GoToB).callMethod("fromto");
//        builder.externalTransition().from(MyState.A).to(MyState.B).on(MyEvent.GoToB).callMethod("fromto");
//        builder.externalTransition().from(MyState.A).to(MyState.B).on(MyEvent.GoToB).callMethod("fromto");
//        builder.externalTransition().from(MyState.A).to(MyState.B).on(MyEvent.GoToB).callMethod("fromto");
//        builder.externalTransition().from(MyState.A).to(MyState.B).on(MyEvent.GoToB).callMethod("fromto");

        UntypedStateMachine stateMachine = builder.newStateMachine(MyState.A);

        stateMachine.start();
        System.out.println(stateMachine.getCurrentState());
        stateMachine.fire(MyEvent.GoToB);
        System.out.println(stateMachine.getCurrentState());

    }

}